﻿<UserControl x:Class="DaveSexton.Labs.PhoneLabHost"
						 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
						 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
						 xmlns:local="clr-namespace:DaveSexton.Labs"
						 xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
						 xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
						 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
						 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
						 mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
						 DataContext="{Binding RelativeSource={RelativeSource Self}}">
	<UserControl.Resources>

		<local:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

	</UserControl.Resources>

	<Grid>

		<phone:Pivot Name="PivotControl">

			<phone:PivotItem Header="Labs">

				<phone:LongListSelector Name="LabList" Margin="0,0,-12,0"
																IsGroupingEnabled="True" LayoutMode="List"
																IsEnabled="{Binding CanChangeLab}"
																ItemsSource="{Binding Labs}">

					<phone:LongListSelector.ItemTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding DisplayName}" Style="{StaticResource PhoneTextNormalStyle}" />
						</DataTemplate>
					</phone:LongListSelector.ItemTemplate>

					<phone:LongListSelector.GroupHeaderTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Category.OrganizedName}" Style="{StaticResource PhoneTextGroupHeaderStyle}" />
						</DataTemplate>
					</phone:LongListSelector.GroupHeaderTemplate>

					<phone:LongListSelector.GroupFooterTemplate>
						<DataTemplate>
							<TextBlock Margin="10" />
						</DataTemplate>
					</phone:LongListSelector.GroupFooterTemplate>

					<phone:LongListSelector.JumpListStyle>
						<Style TargetType="phone:LongListSelector">
							<Setter Property="ItemTemplate">
								<Setter.Value>
									<DataTemplate>
										<Border HorizontalAlignment="Center" CornerRadius="5" Margin="5" MinWidth="360"
														BorderBrush="{StaticResource PhoneSubtleBrush}" BorderThickness="2"
														Background="{StaticResource PhoneSemitransparentBrush}">

											<TextBlock Text="{Binding Category.OrganizedName}" Style="{StaticResource PhoneTextAccentStyle}"
																 FontSize="{StaticResource PhoneFontSizeLarge}"
																 Margin="7" />

										</Border>
									</DataTemplate>
								</Setter.Value>
							</Setter>
						</Style>
					</phone:LongListSelector.JumpListStyle>

				</phone:LongListSelector>

			</phone:PivotItem>

			<phone:PivotItem Name="ConsolePivotItem" Header="Console" IsEnabled="{Binding HasSelectedItem}">

				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition />
						<RowDefinition Height="Auto" />
						<RowDefinition Height="Auto" />
					</Grid.RowDefinitions>

					<ScrollViewer Name="OutputScroll" Grid.Row="0" VerticalScrollBarVisibility="Auto">

						<TextBlock Name="Output" TextWrapping="Wrap" FontFamily="Courier New" FontWeight="Bold" />

					</ScrollViewer>

					<Border Grid.Row="1" Height="1" BorderThickness="1" BorderBrush="{StaticResource PhoneSubtleBrush}" />

					<ContentControl Grid.Row="2" Content="{Binding SelectedLab}"
													VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />

				</Grid>

			</phone:PivotItem>

			<phone:PivotItem Header="Source" IsEnabled="{Binding HasSourceCode}">

				<ScrollViewer Visibility="{Binding HasSourceCode, Converter={StaticResource BooleanToVisibilityConverter}}"
											VerticalScrollBarVisibility="Auto">

					<TextBlock Text="{Binding SourceCode}" TextWrapping="Wrap" FontFamily="Courier New" FontWeight="Bold" />

				</ScrollViewer>

			</phone:PivotItem>

			<phone:PivotItem Header="XAML" IsEnabled="{Binding HasSourceXaml}">

				<ScrollViewer Visibility="{Binding HasSourceXaml, Converter={StaticResource BooleanToVisibilityConverter}}"
											VerticalScrollBarVisibility="Auto">

					<TextBlock Text="{Binding SourceXaml}" TextWrapping="Wrap" FontFamily="Courier New" FontWeight="Bold" />

				</ScrollViewer>

			</phone:PivotItem>

		</phone:Pivot>

	</Grid>

</UserControl>